﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DAO
{
    public class BreedDao:BaseDao
    {
        public Breed Breed { get; set; }

        public List<Breed> GetAllBreed()
        {
            var query = from c in _agiltasticDbEntities.Breed
                        orderby c.Name
                        select c;
            return query.ToList();
        }

        public Breed GetById(int id)
        {
            var query = from c in _agiltasticDbEntities.Breed
                        where c.Id == id
                        select c;
            return query.FirstOrDefault();
        }

        public void Update(Breed currentSelected)
        {
            var breed = GetById(currentSelected.Id);
            breed.Name = currentSelected.Name;
            _agiltasticDbEntities.SaveChanges();
        }

        public void Save(Breed currentSelected)
        {
            _agiltasticDbEntities.Breed.Add(currentSelected);
            _agiltasticDbEntities.SaveChanges();
        }
    }
}
